package myAsm;

import java.util.Map;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Transient;

import org.objectweb.asm.MethodVisitor;


@Entity
@DiscriminatorValue("INSN_METHOD")
public class MyMethodInsnNode extends MyAbstractInsnNode {

	 /**
     * The internal name of the method's owner class (see
     * {@link org.objectweb.asm.Type#getInternalName() getInternalName}).
     */
	@Transient
    public String owner;

    /**
     * The method's name.
     */
	@Transient
    public String name;

    /**
     * The method's descriptor (see {@link org.objectweb.asm.Type}).
     */
	@Transient
    public String desc;

	public MyMethodInsnNode(){
		super(-1);
	}
	
    /**
     * Constructs a new {@link MethodInsnNode}.
     * 
     * @param opcode the opcode of the type instruction to be constructed. This
     *        opcode must be INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC,
     *        INVOKEINTERFACE or INVOKEDYNAMIC.
     * @param owner the internal name of the method's owner class (see
     *        {@link org.objectweb.asm.Type#getInternalName() getInternalName})
     *        or {@link org.objectweb.asm.Opcodes#INVOKEDYNAMIC_OWNER}.
     * @param name the method's name.
     * @param desc the method's descriptor (see {@link org.objectweb.asm.Type}).
     */
    public MyMethodInsnNode(
        final int opcode,
        final String owner,
        final String name,
        final String desc)
    {
        super(opcode);
        this.owner = owner;
        this.name = name;
        this.desc = desc;
    }

    /**
     * Sets the opcode of this instruction.
     * 
     * @param opcode the new instruction opcode. This opcode must be
     *        INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or INVOKEINTERFACE.
     */
    public void setOpcode(final int opcode) {
        this.opcode = opcode;
    }

    public int getType() {
        return METHOD_INSN;
    }

    public void accept(final MethodVisitor mv) {
        mv.visitMethodInsn(opcode, owner, name, desc);
    }

    public MyAbstractInsnNode clone(final Map labels) {
        return new MyMethodInsnNode(opcode, owner, name, desc);
    }
}